<?php
class Utility_Email
{
    protected static $_instance;
    
    public static function getInstance()
    {
        if (empty(self::$_instance)) {
            self::$_instance = new Utility_Email();
        }
        return self::$_instance;
    }
    
    /**
     * 发送电子邮件给用户
     * 将来记得写入配置中 待完成
     *
     * @param $title, $description
     *            标题和描述
     */
    public function sentEmail($title, $description, $to)
    {
        error_reporting(E_ALL);
        // Create SMTP connection Object
        $configInfo = array(
            'auth' => 'login',
            'username' => 'root',
            'password' => 'ilovezwbwza',
            'port' => '25'
        );
        $smtpHost = new Zend_Mail_Transport_Smtp('127.0.0.1', $configInfo);
        // Send out the welcome message
        $mailObj = new Zend_Mail("UTF-8");
        $emailMessage = "<p>$title</p><p>$description</p>";
        $fromEmail = "system@ilovemedia.com";
        $fromFullName = "ilovemedia";
        $subject = $title;
        $mailObj->setBodyHtml($emailMessage);
        $mailObj->setFrom($fromEmail, $fromFullName);
        $mailObj->addTo($to);
        $mailObj->setSubject($subject);
        $mailObj->send();
    }
}